﻿using IBLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        public IUserBLL Bll { get; }

        public UserController(IUserBLL bll)
        {
            Bll = bll;
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="PageIndex">当前页</param>
        /// <param name="PageSize">页容量</param>
        /// <param name="name">姓名 模糊</param>
        /// <param name="lx">类型 下拉</param>
        /// <returns>通过分页+条件查询来返回数据</returns>
        [HttpGet]
        public UserDTO UShow(int PageIndex, int PageSize, string? name, string? lx)
        {
            return Bll.UShow(PageIndex, PageSize, name, lx);
        }
        /// <summary>
        /// 逻辑批量删除
        /// </summary>
        /// <param name="ids">居民id</param>
        /// <returns>返回匿名函数</returns>
        [HttpGet]
        public async Task<int> Del(string? ids)
        {
            
            return await Bll.Del(ids);
        }
        /// <summary>
        /// 批量修改状态
        /// </summary>
        /// <param name="ids">居民id</param>
        /// <returns>返回匿名函数</returns>
        [HttpGet]
        public async Task<int> Upd(string? ids)
        {
            
            return await Bll.Upd(ids);
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="ids">居民id</param>
        /// <returns>查询某一条数据</returns>
        [HttpGet]
        public User Fan(int ids)
        {
           return Bll.Fan(ids);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="m">居民信息</param>
        /// <returns>修改受影响行数</returns>
        [HttpPut]
        public async Task<int> Update(User m)
        {
            return await Bll.Update(m);
        }

    }
}
